package com.ruoyi.order.controller;

import com.repair.api.order.request.param.OrderAssignParam;
import com.repair.api.order.request.param.OrderQueryParam;
import com.repair.api.order.response.vo.OrderVO;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chunyu
 * @since 2024/10/19,17:48
 */
@RestController
@RequestMapping("/admin/order/")
@Api(tags = "订单管理模块")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @ApiOperation("查询全部订单")
    @GetMapping("getAllOrders")
    public R<TableDataInfo> getAllOrders(OrderQueryParam orderQueryParam) {
        TableDataInfo tableDataInfo = orderService.getAllOrders(orderQueryParam);
        return R.ok(tableDataInfo);
    }

    @ApiOperation("查看订单详情")
    @GetMapping("getOrderDetail")
    public R<OrderVO> getOrderDetail(String orderNum) {
         OrderVO orderVO = orderService.getOrderDetail(orderNum);
        return R.ok(orderVO);
    }

    @ApiOperation("给师傅派单")
    @PostMapping("assignOrder")
    public R<String> assignOrder(@RequestBody OrderAssignParam param) {
        orderService.assignOrder(param);
        return R.ok("派单成功");
    }

    @ApiOperation("入抢单池")
    @PostMapping("addGrabPool")
    public R<String> addGrabPool(String orderNum) {
        orderService.addGrabPool(orderNum);
        return R.ok("入抢单池成功");
    }

}
